package org.example.minebackend.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.minebackend.pojo.Passage;
import org.example.minebackend.pojo.Result;
import org.example.minebackend.service.PassageDataService;
import org.example.minebackend.service.impl.PassageDataServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin("*")
@Slf4j
public class PassageDataController {
    @Autowired
    private PassageDataService passageDataService;

    @GetMapping("/passages/{kind}")
    public Result getPassageData(@PathVariable String kind) {
        log.info("请求文章信息，类型为：{}(0代表宅家，1代表在外)", kind);
        List<Passage> passages = passageDataService.getPassageData(kind);
        return Result.success(passages);
    }
}
